<template>
	<view>
		<!-- 导航栏组件 -->
		<index-nav-bar :router="router"></index-nav-bar>

		<!-- 置顶底图 -->
		<view class="background-image"></view>

		<!-- 质保激活区域 -->
		<view class="warranty-block" @click="gotoWarranty">
			<image src="https://tongrenlijiaojing.oss-cn-beijing.aliyuncs.com/wechat/quality/zhibaobanner.png"
				mode="widthFix" style="width: 100%"></image>
		</view>

		<!-- 原有商品列表内容 -->
		<view class="product-card" @click="gotoAppoint()">
			<view class="product-image">
				<image mode="widthFix" :src="appoiont_index_banner"></image>
			</view>
		</view>
		<view class="footer-container">
			<image class="footer-image"
				src="https://tongrenlijiaojing.oss-cn-beijing.aliyuncs.com/wechat/index_footer.png" mode="widthFix">
			</image>
		</view>

	</view>
</template>

<script>
	import indexNavBar from '../component/indexNavBar.vue';
	export default {
		components: {
			indexNavBar
		},
		props: {},
		data() {
			return {
				goodsList: [],
				appoiont_index_banner: '',
				router: '',
			};
		},
		onShareAppMessage() {
			return {
				title: '青少年近视防控领先方案', // 分享标题
				path: '/pages/index/index2', // 分享路径
				imageUrl: 'https://tongrenlijiaojing.oss-cn-beijing.aliyuncs.com/wechat/wechat_share.png', // 分享图片，这里使用生成的二维码图片
				success: function(res) {
					// 转发成功
					console.log("转发成功:");
				},
				fail: function(res) {
					// 转发失败
					console.log("转发失败:");
				}
			}
		},
		onLoad() {
			const that = this
			let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
			that.router = routes[routes.length - 1].route // 获取当前页面路由，也就是最后一个打开的页面路由
			that.$http.GET('/app/order/order/getImageUrl', {}, res => {
				console.log(res)
				that.appoiont_index_banner = res.data.appoiont_index_banner
			})
			uni.removeStorageSync('shopId')
		},
		methods: {
			gotoAppoint() {
				this.$tools.routerTo('/pages/index/appointDetail', 'navigateTo', 'none')
				// this.$tools.routerTo('/pages/index/index', 'switchTab', 'none')
			},
			gotoWarranty() {
				this.$tools.routerTo('/pages/quality/scanQuality', 'navigateTo', 'none')
			},
			// 设置生日
			setBirthDay(e) {
				const value = e.detail.value.split('-');
				this.userForm.birthday = `${value[0]}-${value[1].padStart(2, '0')}-${value[2].padStart(2, '0')}`;
			},

		}
	};
</script>

<style scoped lang="css">

	/* 置顶底图样式 */
	.background-image {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-image: url('https://tongrenlijiaojing.oss-cn-beijing.aliyuncs.com/wechat/index_back.png');
		background-size: cover;
		background-position: center;
		z-index: -1;
		/* 置于底层 */
	}

	/* 质保激活区域样式 */
	.warranty-block {
		margin: 240rpx 35rpx 0rpx 35rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.warranty-text {
		color: #2ac8a6;
		font-size: 28rpx;
		font-weight: 500;
	}

	.warranty-activate {
		background-color: #2ac8a6;
		color: #fff;
		padding: 8rpx 24rpx;
		border-radius: 20rpx;
		font-size: 24rpx;
	}

	/* 添加顶部边距，避免被导航栏遮挡 */
	.product-card {
		background-color: transparent;
		border-radius: 0;
		margin: 10rpx auto;
		/* 水平居中 */
		box-shadow: none;
		width: 100%;
		/* 卡片宽度100% */
	}

	.product-image {
		width: 100%;
		text-align: center;
		/* 容器内居中 */
		border-radius: 16rpx;
		overflow: hidden;
	}

	.product-image image {
		width: 98%;
		/* 图片宽度为屏幕80% */
		height: auto;
		/* 高度自适应 */
		display: block;
		/* 确保margin生效 */
		margin: 0 auto;
		/* 水平居中 */
	}

	/* 底部图片样式 */
	.footer-container {
		text-align: center;
	}

	.footer-image {
		width: 80%;
		margin: auto;
	}
</style>